<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生信息-首页</title>
  <script type="text/javascript">
    function show(){
      var td = event.srcElement;
      var tr = td.parentElement;
      tr.style.backgroundColor="red";
    }

    function clearColor(){
      var td = event.srcElement;
      var tr = td.parentElement;
      tr.style.backgroundColor="transparent";
    }

    function delStudent(id) {
      if(confirm('是否确认删除?')){
        window.location.href='del.do?id='+id;
      }
    }

    function page(pageNo){
      window.location.href="student?pageNo="+pageNo
    }
  </script>
</head>
<body>

<h3 align="center">学生管理首页</h3><br><br>

<form th:action="@{search.do}" method="post">
  <input type="hidden" name="oper" value="search">
  请输入查询的名字：<input type="text" name="keyword">
                <input type="submit" value="搜索">
</form>
<div align="right"> <a href="index.html">添加</a></div>
<div align="center">
  <table align="center" width="100%"border="1" cellspacing="0">
    <tr align="center" >
    <th>name </th>
    <th>age</th>
    <th>phone</th>
    <th>address</th>
      <th height="45">delete</th>
    </tr>
    <tr align="center" th:if="${#lists.isEmpty(session.studentList)}">
      <td colspan="4">null</td>
    </tr>

    <tr align="center"  onmousemove="show()" onmouseout="clearColor()" th:unless="${#lists.isEmpty(session.studentList)} "
      th:each="student : ${session.studentList}"
    >


      <!--/*@thymesVar id="student" type="com.tencent.pojo.Student"*/-->
<!--      <td><a th:href="@{'/edit.dao' + ?sid=${student.id}}" th:text="${student.name}" ></a></td>-->
      <td><a th:text="${student.name}" th:href="@{/edit.dao(fid=${student.id})}">1</a></td>
      <td th:text="${student.age}">1</td>
      <td th:text="${student.phone}">1</td>
      <td th:text="${student.address}">1</td>
      <td><img src="del.jpeg" width="38" th:onclick="'delStudent('+${student.id}+')'"/></td>
<!--      <td><img src="del.jpeg" width="40" th:onclick="'delStudent('+${student.id}+')'"/></td>-->
<!--      <td><img src="del.jpeg" width="40" th:onclick="|delStudent(${student.id})|"/></td>-->

    </tr>
  </table>
</div>
<div>
  <input type="button" value="首页" th:onclick="|page(1)|" th:disabled="${session.pageNo==1}">
  <input type="button" value="上一页" th:onclick="|page(${session.pageNo-1})|" th:disabled="${session.pageNo==1}">
  <input type="button" value="下一页" th:onclick="|page(${session.pageNo+1})|" th:disabled="${session.pageNo==session.pageEnd}">
  <input type="button" value="尾页" th:onclick="|page(${session.pageEnd})|" th:disabled="${session.pageNo==session.pageEnd}">
  <a href="student">回到首页</a>
</div>
</body>
</html>